package com.yowasa.xiuxian.engine.battle.buff;

import com.yowasa.xiuxian.annoations.Buff;
import com.yowasa.xiuxian.entity.bo.battle.BattleContent;
import com.yowasa.xiuxian.entity.bo.battle.BuffContent;
import com.yowasa.xiuxian.entity.bo.battle.UserBattleContent;

import java.math.BigDecimal;


@Buff(name = "巴印")
public class BaYinBuff implements BuffInterface {

    @Override
    public void afterBuffAction(UserBattleContent first, UserBattleContent second, BattleContent content) {
        BuffContent buff = first.getBuff().get("巴印");
        if (buff.getNum() >=1){
            int num = buff.getNum();
            first.getBuff().get("巴印").setNum(0);
            int atk = second.getBattleInfo().getAtk();
            int v = (atk / 4 )* num;
            first.getBattleInfo().setChp(first.getBattleInfo().getChp() - v);

            //最大回复
            BigDecimal divide = new BigDecimal(v).multiply(new BigDecimal(second.getBattleInfo().getRestoreRate())).divide(new BigDecimal(400),0);
            int spell = divide.intValue();
            //当前损失血量
            int needHp = first.getBattleInfo().getHp() - first.getBattleInfo().getChp();

            int can = Math.min(needHp, spell);
            second.getBattleInfo().setChp(second.getBattleInfo().getChp() + can);
            content.getMsgLog().add(first.getUserBO().getName() + "因巴印引爆失去了" + v + "点hp，"+second.getUserBO().getName()+"回复了"+can+"点hp");
        }

    }
}
